package com.itheima.service.impl;

import com.github.pagehelper.PageHelper;
import com.itheima.domain.Banner;
import com.itheima.domain.BannerExample;
import com.itheima.mapper.BannerMapper;
import com.itheima.service.BannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BannerServiceImpl implements BannerService {

    @Autowired
    private BannerMapper bannerMapper;

    @Override
    public List<Banner> findBannerList() {
        //SELECT * FROM tb_banner ORDER BY order_no DESC LIMIT 0,5;
        //设置分页条件
        PageHelper.startPage(1,5);
        //设置排序条件
        BannerExample bannerExample = new BannerExample();
        bannerExample.setOrderByClause("order_no DESC");
        //执行查询
        List<Banner> bannerList = bannerMapper.selectByExample(bannerExample);

        return bannerList;
    }
}
